package net.mengkang.response;

import net.mengkang.utils.TraceUtil;

public class DataResult<T> {
    private boolean success;
    private int code;
    private String message;
    private String traceId;
    private T data;

    public static <T> DataResult<T> success(T data) {
        DataResult<T> dataResult = new DataResult<>();
        dataResult.setSuccess(true);
        dataResult.setCode(200);
        dataResult.setMessage("OK");
        dataResult.setData(data);
        dataResult.setTraceId(TraceUtil.get());
        return dataResult;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getTraceId() {
        return traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
